<?php
namespace app\admin\validate;

use think\Validate;
use think\Db;

class Lucky extends Validate
{

    // 验证规则
    protected $rule = [
        'name' => 'require|min:2|max:50',
        'img' => 'require',
        'money' => 'requireIf:type,1|gt:0|number',
        'day' => 'requireIf:type,1|gt:0|number',
        'prob' => 'require|number',
    ];
    //错误信息
    protected $message = [
        'name.require' => '奖品名称必填',
        'name.min' => '奖品名称长度至少2个字符',
        'name.max' => '奖品名称长度至多50个汉字',
        'img.require' => '奖品图片必须上传',
        'money.requireIf' => '抵扣金额必填',
        'money.gt' => '抵扣金额必须大于0',
        'money.number' => '抵扣金额只能为数字',
        'day.requireIf' => '有效时间必填',
        'day.gt' => '有效时间必须大于0',
        'day.number' => '有效时间只能为数字',
        'prob.require' => '奖励概率必填',
        'prob.number' => '奖励概率只能为数字',
    ];
}